import axios from "axios";
import cookie from "js-cookie";

//创建axios实例
const service = axios.create({
  baseURL: 'http://localhost:8666',
  timeout: 20000  //请求超时时间
})

//http request 拦截器
service.interceptors.request.use(
  config => {

    //  判断cookie里面是否有名称是yydm_toKen的数据
    if (cookie.get('yydm_toKen')) {
      //  把获取的toKen值放到header里面
      config.headers['toKen'] = cookie.get('yydm_toKen');
    }
    return config;
  },
  err => {
    return Promise.reject(err);
  }
)


export default service
